package com.mao.crowd.mvc.config;


import entity.Admin;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.List;

/**
 * @author: Administrator
 * @description: 让User对象中包含原始的user对象,能够获取到更多的对象属性
 * @cteate 2021-06-09-23:44
 */
public class SecurityAdmin extends User {

    private static final long serialVersionUID = 1L;

    private Admin orginalAdmin;

    public SecurityAdmin(Admin orginalAdmin, List<GrantedAuthority> authorities) {
        super(orginalAdmin.getLoginAcct(),orginalAdmin.getUserPswd(), authorities);

        this.orginalAdmin = orginalAdmin;

        // 做账号密码的校验是用封装的信息做的，不用里面的密码
        this.orginalAdmin.setUserPswd(null);
    }

    public Admin getOrginalAdmin() {
        return orginalAdmin;
    }
}
